<template>
    <div class="box6">
        <div class="title">
            <p>景区排行</p>
            <img src="../../images/dataScreen-title.png" alt="">
        </div>
        <div class="charts" ref="charts"></div>
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

// 获取charts节点
let charts = ref<any>()

onMounted(() => {
    // 获取charts类的实例
    let mycharts = echarts.init(charts.value)
    // 设置实例配置项
    mycharts.setOption({
        // 标题组件
        title: {
            text: '景区排行',
            link: 'http://www.baidu.com',
            left: '50%',
            textStyle: {
                color: 'yellowgreen',
                fontSize: 20
            },
            subtext: '各大景区排行',
            subtextStyle: {
                color: 'yellowgreen',
                fontSize: 16
            }
        },
        // x|y轴组件
        xAxis: {
            type: 'category',
        },
        yAxis: {
        },
        // 布局组件
        grid: {
            left: 20,
            right: 20,
            top: 0,
            bottom: 20
        },
        // 系列：决定展示什么样的图形
        series: [
            {
                type: 'bar',
                data: [10, 20, 30, 40, 50, 60, 70],
                label: {
                    show: true,
                    position: 'insideTop',
                    color: 'yellowgreen'
                },
                showBackground: true,
                backgroundStyle: {
                    color: {
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 0,
                        y2: 1,
                        colorStops: [{
                            offset: 0, color: '#67563A'
                        }, {
                            offset: 1, color: '#10164A'
                        }],
                        global: false
                    }
                },
                itemStyle: {
                    borderRadius: [5, 5, 0, 0],
                    color: function (data: any) {
                        let arr = ['red', 'orange', 'yellowgreen', 'green', 'purple', 'hotpink', 'skyblue']
                        return arr[data.dataIndex]
                    }
                }
            },
            {
                type: 'line',
                data: [10, 20, 30, 40, 50, 60, 90],
                smooth: true
            },
        ],
        tooltip: {
            backgroundColor:'rgba(50,50,50,0.7)'
        }
    })
})
</script>

<style scoped lang="scss">
.box6 {
    width: 100%;
    height: 100%;
    background: url('../../images/dataScreen-main-cb.png') no-repeat;
    background-size: 100% 100%;
    margin: 20px 0;

    .title {
        margin-left: 5px;

        p {
            color: #fff;
            font-size: 20px;
        }
    }

    .charts {
        height: calc(100% - 30px);
    }
}
</style>